package org.sag.mallbf;

import org.sag.mallbf.type.DataType;

import java.io.DataOutputStream;
import java.util.ArrayList;

/**
 * Polygon Object Spec
 *
 * --> Version
 * Int16 Type: OBJECT
 * Int16 Version = 4
 *
 * --> Version Info
 * Int32 Segment Count
 *
 * --> Trunk Area
 */
public class PolygonObject {
    ArrayList<ObjSegment> segments = new ArrayList<>();
    String name = "";

    public PolygonObject() {
        segments = new ArrayList<>();

        ObjSegment segment = new ObjSegment();

        segments.add(segment);
    }

    public void exportTo(DataOutputStream dos, int version) throws Exception {

        Utils.putShort(dos, (short) DataType.OBJECT.getValue(), 0);
        Utils.putShort(dos, (short) version, 0);

        Utils.putInt(dos, segments.size(), 1);

        for (ObjSegment s : segments) {
            s.exportTo(dos, version);
        }
    }
}
